import {reqGetSearchList} from "@/api";

const state = {
	searchList: []   // 初始数据
};
const getters = {  // 通过计算属性 帮我们 快速得到里面的 数据
	attrsList(state) {
		return state.searchList.attrsList
	},
	goodsList(state) {
		return state.searchList.goodsList
	},
	trademarkList(state) {
		return state.searchList.trademarkList
	},
	pageNo(state) {  // 当前页
		return state.searchList.pageNo
	},
	total(state) {  // 总数量
		return state.searchList.total
	},
	totalPages(state) {  // 总页数
		return state.searchList.totalPages
	}
};
const mutations = {
	SET_SEARCHLIST_STATE(state, payload) {
		state.searchList = payload.searchList
	}
};
const actions = {
	async getSearchList({commit}, searchUrl) {
		const result = await reqGetSearchList(searchUrl);
		commit('SET_SEARCHLIST_STATE', {searchList: result})
	}
};

export default {
	namespaced: true,
	state,
	getters,
	mutations,
	actions
}